import request from "@/utils/request.js";

export function ApiSchemalList(data) {
    return request({
        url: '/v1/cmdb/schema',
        method: 'get',
        params: data
    })
}

export function ApiSchemalDetail(id) {
    return request({
        url: '/v1/cmdb/schema-detail/' + id,
        method: 'get',
    })
}

export function ApiInstancelDetail(entity_id) {
    return request({
        url: '/v1/cmdb/instance-detail/' + entity_id,
        method: 'get',
    })
}


export function ApiSchemaCreate(data) {
    return request({
        url: '/v1/cmdb/schema',
        method: 'post',
        data: data
    })
}

export function ApiSchemaUpdate(data) {
    return request({
        url: '/v1/cmdb/schema',
        method: 'put',
        data: data
    })
}

export function ApiSchemaDelete(id) {
    return request({
        url: '/v1/cmdb/schema/' + id,
        method: 'delete',
    })
}

export function ApiFieldList(schema_id) {
    return request({
        url: '/v1/cmdb/field/' + schema_id,
        method: 'get',
    })
}

export function ApiFieldCreate(schema_id, data) {
    return request({
        url: '/v1/cmdb/field/' + schema_id,
        method: 'post',
        data: data
    })
}


export function ApiInstanceList(data) {
    return request({
        url: '/v1/cmdb/instance-list',
        method: 'post',
        data: data
    })
}

export function ApiInstanceCreate(data) {
    return request({
        url: '/v1/cmdb/instance',
        method: 'post',
        data: data
    })
}

export function ApiInstanceUpdate(data) {
    return request({
        url: '/v1/cmdb/instance',
        method: 'put',
        data: data
    })
}

export function ApiInstanceDelete(instance_id) {
    return request({
        url: '/v1/cmdb/instance/' + instance_id,
        method: 'delete',
    })
}

export function ApiModelSwiftCreate(data) {
    return request({
        url: '/v1/cmdb/model-swift-create',
        method: 'post',
        data: data
    })
}

export function ApiModelSwiftRemove(data) {
    return request({
        url: '/v1/cmdb/model-swift-remove',
        method: 'post',
        data: data
    })
}

export function ApiInstanceHistory(data) {
    return request({
        url: '/v1/cmdb/instance-history',
        method: 'get',
        params: data
    })
}

export function ApiInstanceImportExcel(data) {
    return request({
        url: '/v1/cmdb/instance-import-excel',
        method: 'post',
        headers: {'Content-Type': 'multipart/form-data'},
        data: data,
    })
}

export function ApiFieldUpdate(data) {
    return request({
        url: '/v1/cmdb/field',
        method: 'put',
        data: data
    })
}